<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">

        var geocoder;
        var map;
        function initialize() {
            geocoder = new google.maps.Geocoder();
            var latlng = new google.maps.LatLng(37.515144, -121.96891);
            var myOptions = {
                zoom: 8,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
        }

        function codeAddress(address) {
            geocoder.geocode({ 'address': address}, function(results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    map.set_center(results[0].geometry.location);
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location
                    });
                } else {
                    alert("Geocode failed: " + status + ", " + address);
                }
            });
        }


        function showAddresses() {
            var listings = document.getElementById("addresses").value;
            var lines = listings.split("\n")
            for (var i = 1; i < lines.length; i++) {
                var fields = lines[i].split("\",\"")
                var address = fields[3] + ", " + fields[5] + ", CA"
                codeAddress(address)
            }
        }
    </script>
</head>

<body onload="initialize()">
<div id="map_canvas" style="width: 100%; height: 480px;"></div>
<div>
    <textarea id="addresses" cols="100" rows="1"></textarea>
    <input type="button" value="Encode" onclick="showAddresses()">
</div>
</body>
</html>

